import { LOGIN,CREATE } from "../constants/user"

const initialState = {
  user_id:'0',
  user_name:'745595613',
  nickname:'nickname',
  user_photo:'https://t11.baidu.com/it/u=3005961094,4112124005&fm=58',
  creating:false,
  token:'',
}

const loginReducer = (state = initialState, { type, payload }) => {
  const copy = {...state}
  switch (type) {
  case LOGIN:
    copy.user_id = payload.user_id
    copy.user_name = payload.user_name
    copy.nickname = payload.nickname
    copy.user_photo = payload.user_photo
    copy.token = payload.token
    return copy
  case CREATE:
    copy.creating = payload
    return copy
  default:
    return state
  }
}

export default loginReducer